package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.JxStudentScheduleDao;
import io.renren.modules.sys.entity.JxStudentScheduleEntity;
import io.renren.modules.sys.service.JxStudentScheduleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("jxStudentScheduleService")
public class JxStudentScheduleServiceImpl extends ServiceImpl<JxStudentScheduleDao, JxStudentScheduleEntity> implements JxStudentScheduleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<JxStudentScheduleEntity> page = this.page(
                new Query<JxStudentScheduleEntity>().getPage(params),
                new QueryWrapper<JxStudentScheduleEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<JxStudentScheduleEntity> allocatedStudentIds(Map<String, Object> params) {
        return this.baseMapper.allocatedStudentIds(params);
    }

    @Override
    public Integer addBatchStudentSchedule(List<JxStudentScheduleEntity> entities) {
        return this.baseMapper.addBatchStudentSchedule(entities);
    }

    @Override
    public PageUtils getAllWithPage(Map<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("page").toString()),Integer.parseInt(params.get("limit").toString()));
        List<JxStudentScheduleEntity> list = this.baseMapper.getList(params);
        PageInfo<JxStudentScheduleEntity> pageInfo = new PageInfo<JxStudentScheduleEntity>(list);
        return new PageUtils(list,(int)pageInfo.getTotal(),pageInfo.getPageSize(),pageInfo.getPageNum());
    }

    @Override
    public List<JxStudentScheduleEntity> getList(Map<String, Object> params) {
        return this.baseMapper.getList(params);
    }

    @Override
    public List<JxStudentScheduleEntity> allSelectDevicesId(Map<String, Object> params) {
        return  this.baseMapper.allSelectDevicesId(params);
    }

    @Override
    public Integer changeStudentSchedule() {
        return this.baseMapper.changeStudentSchedule();
    }
}
